package suanfarumen;

public class day1 {
    public static int search(int[] nums, int target) {
        int high = nums.length-1;
        int low = 0;
        int i= high/2;
        while(high>=low){
            if(nums[high]==target){
                return high;
            }
            if(nums[low]==target){
                return low;
            }
            if (nums[i]==target){
                return i;
            }else if(nums[i]<target){
                low=(high+low)/2;
                i=(high+low)/2;
            }else{
                high=(high+low)/2;
                i=(high+low)/2;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] a = new int[]{-1,0,5};
        System.out.println(search(a,5));
    }
}
